package cn.py.web;

import com.dream.myqiyi.R;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.KeyEvent;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;



public class MyWebViewActivity extends Activity { 
    private WebView webview; 
    private String url;
   
    
  
    public void onCreate(Bundle savedInstanceState) { 
        super.onCreate(savedInstanceState); 
        setContentView(R.layout.more_activity); 
        Intent intent=getIntent();
       url= intent.getStringExtra("url");
        webview = (WebView) findViewById(R.id.webview); 
        //设置WebView属性，能够执行Javascript脚本 
        webview.getSettings().setJavaScriptEnabled(true); 
        
        webview.getSettings().setBuiltInZoomControls(true);
        webview.setScrollBarStyle(0);// 滚动条风格，为0就是不给滚动条留空间，滚动条覆盖在网页上
        webview.getSettings().setSupportZoom(true);// 支持缩放
       
        //加载需要显示的网页 
        webview.loadUrl(url); 
        //设置Web视图 
        webview.setWebViewClient(new HelloWebViewClient ()); 
        
       
    } 
      
    @Override
    //设置回退 
    public boolean onKeyDown(int keyCode, KeyEvent event) { 
        if ((keyCode == KeyEvent.KEYCODE_BACK) && webview.canGoBack()) { 
            webview.goBack(); //goBack()表示返回WebView的上一页面 
            return true; 
        } 
        return false; 
    } 
      
    //Web视图 
    private class HelloWebViewClient extends WebViewClient { 
        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) { 
            view.loadUrl(url); 
            
            return true; 
        } 
    } 
}